/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.frm.bpm.pojo;

import java.io.Serializable;
import java.sql.Timestamp;
import merlion.frm.bpm.entity.CustomerPaymentRecord;
import merlion.frm.bpm.entity.Invoice;
import merlion.frm.bpm.entity.SupplierInvoice;
import merlion.frm.bpm.entity.SupplierPaymentRecord;



public class Transaction implements Serializable{
    
    private Invoice invoice;
    private CustomerPaymentRecord cpr;
    private SupplierInvoice supplierInvoice;
    private SupplierPaymentRecord spr;
    private String transactionType;
    private String companyName;
    private Timestamp date;
    private Double cashCredit;
    private Double cashDebit;
    private Double receivableCredit;
    private Double receivableDebit;
    private Double payableCredit;
    private Double payableDebit;
    
    public Transaction(){
        
    }
    
    public Transaction(Invoice invoice){
        this.transactionType = "Customer Invoice";
        this.companyName = invoice.getCustomer().getCompanyName();
        this.invoice = invoice;
        this.date = invoice.getInvoiceDate();
        
        receivableDebit = invoice.getTotal();
    }
    
    public Transaction(CustomerPaymentRecord cpr){
        this.transactionType = "Customer Payment";
        this.companyName = cpr.getInvoice().getCustomer().getCompanyName();
        this.cpr = cpr;
        this.date = cpr.getPaymentDate();
        
        receivableCredit = cpr.getPaymentAmount();
        cashDebit = cpr.getPaymentAmount();
    }
    
    public Transaction(SupplierInvoice si){
        this.transactionType = "Supplier Invoice";
        this.companyName = si.getSupplier().getSupplierName();
        this.supplierInvoice = si;
        this.date = si.getDateCreated();
        
        payableCredit = si.getInvoiceAmount();
    }
    
    public Transaction(SupplierPaymentRecord spr){
        this.transactionType = "Supplier Payment";
        this.companyName = spr.getSupplierInvoice().getSupplier().getSupplierName();
        this.spr = spr;
        this.date = spr.getSupplierPaymentDate();
        
        payableDebit = spr.getPaymentAmount();
        cashCredit = spr.getPaymentAmount();
    }

    public CustomerPaymentRecord getCpr() {
        return cpr;
    }

    public void setCpr(CustomerPaymentRecord cpr) {
        this.cpr = cpr;
    }

    public Invoice getInvoice() {
        return invoice;
    }

    public void setInvoice(Invoice invoice) {
        this.invoice = invoice;
    }

    public SupplierPaymentRecord getSpr() {
        return spr;
    }

    public void setSpr(SupplierPaymentRecord spr) {
        this.spr = spr;
    }

    public SupplierInvoice getSupplierInvoice() {
        return supplierInvoice;
    }

    public void setSupplierInvoice(SupplierInvoice supplierInvoice) {
        this.supplierInvoice = supplierInvoice;
    }

    public String getTransactionType() {
        return transactionType;
    }

    public void setTransactionType(String transactionType) {
        this.transactionType = transactionType;
    }

    public Double getCashCredit() {
        return cashCredit;
    }

    public void setCashCredit(Double cashCredit) {
        this.cashCredit = cashCredit;
    }

    public Double getCashDebit() {
        return cashDebit;
    }

    public void setCashDebit(Double cashDebit) {
        this.cashDebit = cashDebit;
    }

    public Double getPayableCredit() {
        return payableCredit;
    }

    public void setPayableCredit(Double payableCredit) {
        this.payableCredit = payableCredit;
    }

    public Double getPayableDebit() {
        return payableDebit;
    }

    public void setPayableDebit(Double payableDebit) {
        this.payableDebit = payableDebit;
    }

    public Double getReceivableCredit() {
        return receivableCredit;
    }

    public void setReceivableCredit(Double receivableCredit) {
        this.receivableCredit = receivableCredit;
    }

    public Double getReceivableDebit() {
        return receivableDebit;
    }

    public void setReceivableDebit(Double receivableDebit) {
        this.receivableDebit = receivableDebit;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public Timestamp getDate() {
        return date;
    }

    public void setDate(Timestamp date) {
        this.date = date;
    }
    
    
}
